/**  
 * @author renbangjie renbangjie@126.com  
 * @date 2016年3月14日 上午10:03:42
 * @version V1.0  
 */
package com.yjd.comm.jms;

import java.io.Serializable;

import com.alibaba.fastjson.JSON;
import com.yjd.comm.rpm.RpmServiceKeyEnum;

/**
 * jms消息载体
 * 
 * @author renbangjie renbangjie@126.com
 * @date 2016年3月14日 上午10:03:42
 */
public class MQMessage implements Serializable {

	/**
	 * @Fields serialVersionUID : TODO
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 消息id唯一的
	 */
	private Long jmsId;
	
	/**
	 * 队列名称和msg_id组成联合主键
	 */
	private String queue;

	/**
	 * 服务名称
	 */
	private RpmServiceKeyEnum rpmServiceKeyEnum;

	/**
	 * 消费者
	 */
	private String customer;

	/**
	 * 消息内容
	 */
	private String message;

	/**
	 * 消息处理结果0成功 -1失败
	 */
	private Integer status;
	

	public MQMessage() {
	}

	public MQMessage(Long jmsId, String queue,
			String message, RpmServiceKeyEnum rpmServiceKeyEnum) {
		this.jmsId = jmsId;
		this.queue = queue;
		this.message = message;
		this.rpmServiceKeyEnum = rpmServiceKeyEnum;
	}

	public Long getJmsId() {
		return jmsId;
	}

	public void setJmsId(Long jmsId) {
		this.jmsId = jmsId;
	}

	public String getQueue() {
		return queue;
	}

	public void setQueue(String queue) {
		this.queue = queue;
	}

	public RpmServiceKeyEnum getRpmServiceKeyEnum() {
		return rpmServiceKeyEnum;
	}

	public void setRpmServiceKeyEnum(RpmServiceKeyEnum rpmServiceKeyEnum) {
		this.rpmServiceKeyEnum = rpmServiceKeyEnum;
	}

	public String getCustomer() {
		return customer;
	}

	public void setCustomer(String customer) {
		this.customer = customer;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}
	
	public  <T extends Object> T getObject(Class<T> cs){
		return JSON.parseObject(this.getMessage(), cs);
	}
	
	public  <T extends Object> T getObject(Object obj,Class<T> cs){
		return JSON.parseObject(obj.toString(), cs);
	}

}
